package com.nd.controller.wx;

import com.nd.pojo.vo.wx.*;
import com.nd.service.wx.HomeIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("wx")
public class HomeController {
    @Autowired
    HomeIndexService homeIndexService;
    @RequestMapping("home/index")
    public BaseRespWXVo index() {
        IndexVo indexVo = homeIndexService.queryIndexVo();
        return BaseRespWXVo.ok(indexVo);
    }

    @RequestMapping("goods/count")
    public BaseRespWXVo count(){
        int count = homeIndexService.queryGoodsCount();
        HashMap<String, Integer> map = new HashMap<>();
        map.put("goodsCount",count);
        return BaseRespWXVo.ok(map);
    }
    @RequestMapping("catalog/index")
    public BaseRespWXVo catalogIndex(){
        CatalogIndexVo catalogIndexVo =homeIndexService.queryCatalogIndexVo();
        return BaseRespWXVo.ok(catalogIndexVo);
    }
    @RequestMapping("catalog/current")
    public BaseRespWXVo catalogCurrent(Integer id){
        CatalogCurrentVo catalogCurrentVo = homeIndexService.queryCatalogCurVo(id);
        return BaseRespWXVo.ok(catalogCurrentVo);
    }
    @RequestMapping("groupon/list")
    public BaseRespWXVo grouponList(Integer page,Integer size){
        WxGrouponListVo wxGrouponListVo = homeIndexService.queryGrouponList(page,size);
        return BaseRespWXVo.ok(wxGrouponListVo);
    }
}
